package org.abratuhi.kvngroupware.pubsub;

import java.util.HashMap;

public class Publication<T> {
	
	String publisherId;
	HashMap<String, Value<T>> values = new HashMap<String, Value<T>>();
	
	public Publication(String pubId){
		this.publisherId = pubId;
	}
	
	public void addAttribute(String attributeId, Value<T> value){
		values.put(attributeId, value);
	}
	
	public void removeAttribute(String attributeId){
		values.remove(attributeId);
	}
	
	public void updateAttribute(String attributeId, Value<T> value){
		if(values.containsKey(attributeId)) values.put(attributeId, value);
	}
	
	public boolean containsAttribute(String attributeId){
		return values.containsKey(attributeId);
	}
	
	public Value<T> getValue(String attributeId){
		return values.get(attributeId);
	}
	
	public String getPublisherId(){
		return this.publisherId;
	}
	
	public String[] getAttributeIds(){
		return values.keySet().toArray(new String[values.keySet().size()]);
	}
	

}
